import { getHomeData } from "@/api/home"
interface ProjectType {
  title: string
  subTitle: string
  url: string
  icon:string
}
interface CourseType {
   title: string
  subTitle: string
  url: string
  image:string
}
export const useHomeStore = defineStore('home', {
  state: () => ({
    swipers: [],
    projects: [] as ProjectType[],
    courses: [] as CourseType[],
    swiperProjects: [],
    // show:true//可以提供给axios的
  }),
  actions:{
    async fetchData(){
      const {data} = await getHomeData()
      console.log("🚀 ~ fetchData ~ res:", data)
      const res = data
      if(data.code ===200){
      this.swipers = res.data.swipers
      this.projects = res.data.projects
      this.courses = res.data.courses
      this.swiperProjects = res.data['swiper-projects']
      }else {
        console.error('获取数据失败',res);
      }

    }
  }
})
